<template>
 <div class="wrapper" ref="wrapper">
   <div class="content">
     <slot></slot>
   </div>
 </div>
</template>

<script>
import BScroll from 'better-scroll'
export default {
name: "Scroll",
  data(){
  return {
    srcoll:null,



  }
  },
  props:{
    probeType:{
      type:Number,
      default: 0

    },

    PullUpLoad:{
      type:Boolean,
      default: false

    }

  },
  mounted() {
    this.scroll=new BScroll(this.$refs.wrapper,{
      click:true,
      probeType:this.probetype,
      pullUpLoad:this.PullUpLoad,
    })




    if(this.PullUpLoad) {
      console.log('==========');
      this.scroll.on('pullingUp', () => {
        this.$emit('loaddata')
        console.log('到底了');

        //滚不到底部=》刷新一下
        this.scroll.refresh()

      })
    }

    this.scroll.on('scroll',(pos)=>{
      this.$emit('scrollpos',pos)


    })
  },
  methods:{
    backtotop(x,y,time=500){
      this.scroll.scrollTo(x,y,time)
    },
    refresh(){
      // console.log('图片读取完毕');
      this.scroll.refresh()
    },
    finfishpullup(){
      this.scroll && this.scroll.finishPullUp()
    },
    gety(){
      return this.scroll ? this.scroll.y:0
    }
  }
}
</script>

<style scoped>

</style>
